﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CuaHangMayTinh.DataAccessLayer;
using CuaHangMayTinh.BusinessEntities;
using CuaHangMayTinh.Utilities;
using System.Data;

namespace CuaHangMayTinh.BusinessLogicLayer
{
    public class ChiTietNhapHangManager
    {
        private static ChiTietNhapHangDA adapter = null;

        static ChiTietNhapHangManager()
        {
            if (adapter == null)
                adapter = new ChiTietNhapHangDA();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static int Insert(ChiTietNhapHangEntity entity)
        {
            try
            {
                return adapter.Insert(entity);
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                return 0;
            }
        }

       /// <summary>
       /// 
       /// </summary>
       /// <param name="entity"></param>
       /// <returns></returns>
        public static bool UpDate_MaHDNH(ChiTietNhapHangEntity entity)
        {
            try
            {
                return adapter.UpDate_MaHDNH(entity);
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                return false;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static bool UpDate_MaChiTietNH(ChiTietNhapHangEntity entity)
        {
            try
            {
                return adapter.UpDate_MaChiTietNH(entity);
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                return false;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static DataTable GetAll()
        {
            try
            {
                return adapter.GetAll();
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                return null;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static DataTable Find_MaChiTietNH(int id)
        {
            try
            {
                return adapter.Find_MaChiTietNH(id);
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                return null;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static DataTable Find_MaHDNH(int id)
        {
            try
            {
                return adapter.Find_MaHDNH(id);
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                return null;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static List<ChiTietNhapHangEntity> ConvertToList(DataTable dt)
        {
            return adapter.ConvertToList(dt);
        }
    }
}
